package com.yunji.base.service;


import com.yunji.base.convert.MalfunctionConvert;
import com.yunji.base.dao.IMalfunctionDao;
import com.yunji.base.domain.MalfunctionDO;
import com.yunji.common.model.dto.MalfunctionDTO;
import com.yunji.common.model.params.MalfunctionParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.message.service
 * @Title: MalfunctionService
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-10-30 14:30:02      V1.0        HuaAo       新建类
 */
@Service
@Slf4j
public class MalfunctionService {

    @Resource
    IMalfunctionDao malfunctionDao;

    public List<MalfunctionDO> search(MalfunctionParam param) {
        return malfunctionDao.search(param);
    }

    public Long create(MalfunctionDTO dto) {
        MalfunctionDO malfunction = MalfunctionConvert.convertDTO(dto);
        malfunctionDao.save(malfunction);
        return malfunction.getMalfunctionId();
    }

    public boolean edit(MalfunctionDTO dto) {
        MalfunctionDO malfunction = MalfunctionConvert.convertDTO(dto);
        return malfunctionDao.updateById(malfunction);
    }

    public boolean delete(List<Long> ids) {
        return malfunctionDao.removeByIds(ids);
    }

    public MalfunctionDO selectById(Long id) {
        return malfunctionDao.getById(id);
    }
}